﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server=.;database=duan;uid=sa;pwd=DWX5070954;";

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            var sqlCommandString = "select*from Rus";

            SqlCommand sqlCommand = new SqlCommand(sqlCommandString, sqlConnection);

            var sdr = sqlCommand.ExecuteReader();
            Console.WriteLine("{0}\t{1}\t{2}", "Id", "用户名","年龄");

            while (sdr.Read())
            {
                Console.WriteLine("{0}\t{1}\t{2}", sdr["userId"], sdr["userName"],sdr["userAge"]);

            }
            sqlConnection.Close();
        }

    }
}
